package com.rhb.detector.topsec.domain.model;

public class Rate {
	private String sendRate;
	private String receivingRate;
	
	public Rate(String str){
		String[] ss = str.split("/");
		this.setSendRate(change(ss[0]));
		this.setReceivingRate(change(ss[1]));
		
	}
	
	public String getSendRate() {
		return sendRate;
	}
	public void setSendRate(String sendRate) {
		this.sendRate = sendRate;
	}
	public String getReceivingRate() {
		return receivingRate;
	}
	public void setReceivingRate(String receivingRate) {
		this.receivingRate = receivingRate;
	}
	
	public String toString(){
		return sendRate + "K /" + receivingRate + "K";
	}
	
	private String change(String str) {
		String s = "";
		if (str.indexOf("M") != -1) {
			int i = Integer.parseInt((str.substring(0, str.indexOf("M"))));
			s = Integer.toString(i * 1024);
		} else if (str.indexOf("K") != -1) {
			s = str.substring(0, str.length() - 1);
		} else {
			s = "1";
		}
		return s;
	}

}
